﻿<UserControl x:Class="Tisbi.LawFirm.UI.Views.Controls.Forms.SqlConnectionStringBuilder"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             DataContext="{Binding Source={StaticResource Locator}, Path=SqlConnectionStringViewModel}"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </UserControl.Resources>

    <GroupBox>
        <GroupBox.Header>
            <TextBlock Text="Подключение к СУБД MSSQL"
                       FontSize="14"
                       FontWeight="Bold" />
        </GroupBox.Header>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="1*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <TextBlock Text="Сервер: "
                       VerticalAlignment="Center"
                       Margin="3"
                       Grid.Column="0"
                       Grid.Row="0" />
            <Grid Grid.Column="1"
                  Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <TextBox Margin="3" 
                          x:Name="SqlServerName"
                          Text="{Binding Path=Server, Mode=TwoWay}" />

            </Grid>
            <TextBlock Text="Название БД: "
                       VerticalAlignment="Center"
                       Margin="3"
                       Grid.Column="0"
                       Grid.Row="1" />
            <Grid Grid.Column="1"
                  Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <TextBox Margin="3"
                          x:Name="SqlDatabaseName"
                          Text="{Binding Path=Database, Mode=TwoWay}" />
            </Grid>

            <GroupBox Header="Аутентификация:"
                      Grid.Column="0"
                      Grid.Row="2"
                      Grid.ColumnSpan="2">
                <StackPanel>
                    <RadioButton Content="Проверка подлинности Windows"
                                 Margin="3"
                                 x:Name="SqlAuthTypeWindows"
                                 IsChecked="{Binding Path=IntegratedSecurity, 
                                                UpdateSourceTrigger=PropertyChanged,
                                                Mode=TwoWay}">
                    </RadioButton>
                    <RadioButton Content="Проверка подлинности SQL"
                                 Margin="3"
                                 x:Name="SqlAuthTypeSql">
                        <RadioButton.Style>
                            <Style>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=IntegratedSecurity}"
                                                 Value="False">
                                        <Setter Property="RadioButton.IsChecked"
                                                Value="True" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </RadioButton.Style>
                    </RadioButton>
                    <Grid Visibility="{Binding ElementName=SqlAuthTypeSql, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="1*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Text="Имя пользователя: "
                                   Grid.Column="0"
                                   Grid.Row="0"
                                   Margin="3"
                                   VerticalAlignment="Center" />
                        <TextBox Grid.Column="1"
                                 Grid.Row="0"
                                 Margin="3"
                                 Text="{Binding Path=UserName, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
                        <TextBlock Text="Пароль: "
                                   Grid.Column="0"
                                   Grid.Row="1"
                                   Margin="3"
                                   VerticalAlignment="Center" />
                        <TextBox Grid.Column="1"
                                 Grid.Row="1"
                                 Margin="3"
                                 Text="{Binding Path=Password, 
                                    UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
                    </Grid>
                </StackPanel>
            </GroupBox>
        </Grid>
    </GroupBox>
</UserControl>
